package com.twu.biblioteca.menu;

import com.twu.biblioteca.*;

public class UserInformationMenuItem implements MenuItem {
    @Override
    public String getName() {
        return "Display My Info";
    }

    @Override
    public String getMnemonic() {
        return "d";
    }

    @Override
    public PostMenuItemAction execute(Library library, UserIO io, UserRepository repository) {
        User user = repository.getLoggedInUser();

        io.println("Account number: " + user.getAccountNumber());
        io.println("Name: " + user.getName());
        io.println("Email address: " + user.getEmailAddress());
        io.println("Phone number: " + user.getPhoneNumber());

        return PostMenuItemAction.Continue;
    }

    @Override
    public boolean shouldDisplay(User currentUser) {
        if (currentUser == null) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public int getPriority() {
        return MenuItem.PRIORITY_USERS + 1;
    }
}
